package com.wanmait.schedule.controller;

import com.wanmait.schedule.entity.ClassroomType;
import com.wanmait.schedule.entity.Teacher;
import com.wanmait.schedule.service.ClassroomTypeService;
import com.wanmait.schedule.util.AjaxResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 教室类型表 前端控制器
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@RestController
@RequestMapping("/manage/classroomType")
@RequiresPermissions("manage:classroom")
public class ClassroomTypeController {
    @Resource
    private ClassroomTypeService classroomTypeService;
    //添加
    @PostMapping("insert")
    public AjaxResult insert(@RequestBody ClassroomType classroomType, @RequestAttribute Teacher teacher){
        classroomType.setInputId(teacher.getId());
        classroomTypeService.save(classroomType);
        return AjaxResult.success("添加成功");
    }
    //修改
    @PostMapping("update")
    public AjaxResult update(@RequestBody ClassroomType classroomType){
        classroomTypeService.updateById(classroomType);
        return AjaxResult.success("成功");
    }
    //列表
    @GetMapping("list")
    public AjaxResult list(){
        return AjaxResult.success(classroomTypeService.list());
    }
    //删除
    @GetMapping("delete")
    public AjaxResult delete(Integer id){
        classroomTypeService.removeById(id);
        return AjaxResult.success("删除成功");
    }
}
